﻿<Window 
    x:Class="BingVis.WPFClient.MainShell"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:ve="clr-namespace:InfoStrat.VE;assembly=InfoStrat.VE"
    xmlns:veUtil="clr-namespace:InfoStrat.VE.Utilities;assembly=InfoStrat.VE"
    xmlns:com="clr-namespace:BingVis.Common;assembly=BingVis.Common"
    xmlns:local="clr-namespace:BingVis.WPFClient"
    xmlns:visualizationToolkit="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
    xmlns:cinch="clr-namespace:Cinch;assembly=Cinch"    
    WindowState="Normal"
    Title="MBTA Fare Visualization" MinHeight="600" MinWidth="800">
    
    <Window.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary
                    Source="Styles/ClientStyle.xaml" />
            </ResourceDictionary.MergedDictionaries>
            
            <local:TransitStopToPushPinConverter x:Key="StopToPushPinCvt" />
            
            <Style x:Key="LoadyStyle" TargetType="{x:Type TextBlock}">
                <Style.Triggers>
                    <Trigger Property="Visibility" Value="Visible">
                        <Trigger.EnterActions>
                            <BeginStoryboard>
                                <Storyboard RepeatBehavior="Forever">
                                <DoubleAnimation AutoReverse="True"                                        
                                            Storyboard.TargetProperty="Opacity"
                                            To="0.9"
                                            Duration="0:0:0.8"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.EnterActions>
                        <Trigger.ExitActions>
                            <BeginStoryboard>
                                <Storyboard>
                                <DoubleAnimation 
                                            Storyboard.TargetProperty="Opacity"
                                            To="0.0"
                                            Duration="0:0:0.5"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </Trigger.ExitActions>
                    </Trigger>
                </Style.Triggers>
            </Style>
        </ResourceDictionary>
    </Window.Resources>
    <Grid Background="#282828">
        <Menu
        Background="{StaticResource DarkGrayBrush}"
        VerticalAlignment="Top"
        HorizontalAlignment="Stretch"        
        Height="20"
        Foreground="WhiteSmoke">
            <Menu.Items>
                <MenuItem Header="File" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Load Fare Gate File" Command="{Binding ShowFareFileSelector}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Load Compressed Fare Gate File" Command="{Binding ShowCompressedFareFileSelector}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Compress Fare Gate File" Command="{Binding ShowCompressFileSelector}" />
                </MenuItem>
                <MenuItem Header="View" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem IsCheckable="True" IsChecked="{Binding Show3DBuildings}" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Show/Hide 3D Buildings" Command="{Binding ToggleShow3DBuildings}" CommandParameter="{Binding Show3DBuildings}" />
                </MenuItem>
                <MenuItem Header="Help" Background="{StaticResource DarkGrayBrush}" Foreground="LightGray">
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="Basic Help" Command="{Binding ShowBasicHelp}" />
                    <MenuItem Background="{StaticResource DarkGrayBrush}" Foreground="LightGray"
                        Header="About..." Command="{Binding ShowAbout}" />
                </MenuItem>
            </Menu.Items>
        </Menu>
        <Grid x:Name="LayoutRoot" Style="{StaticResource LayoutRootStyle}" Margin="0 20 0 3">        
        
        <Grid.RowDefinitions>
            <RowDefinition Height="80*" />
            <RowDefinition Height="20*" MaxHeight="300" />
        </Grid.RowDefinitions>
        <Grid.ColumnDefinitions>
            <ColumnDefinition Width="35*" MaxWidth="350" />
            <ColumnDefinition Width="65*" />
        </Grid.ColumnDefinitions>
        
        <!-- Left Pane -->
        <Border Style="{StaticResource LeftPaneStyle}"
            Grid.Column="0"
            Grid.Row="0"            
            >
                <Grid>
                    <TextBox
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Top"
                        Margin="0 0 60 0"
                        Height="20"                        
                        Foreground="Black"
                        Background="LightGray"                                    
                        cinch:SingleEventCommand.RoutedEventName="KeyDown"
                        cinch:SingleEventCommand.TheCommandToRun="{Binding FilterOnEnter}"
                        Text="{Binding StopsFilter, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}">
                        <TextBox.ToolTip>
                            <StackPanel>
                                <TextBlock Foreground="Black" Text="'&lt;search filter&gt;' or '$ &lt;search filter&gt;' to show only stops with fares."></TextBlock>
                            </StackPanel>
                        </TextBox.ToolTip>
                    </TextBox>
                        
                    <Button
                        HorizontalAlignment="Right"
                        VerticalAlignment="Top"
                        Height="20"
                        Width="50"
                        Content="Filter"
                        Command="{Binding StopsList.FilterStops}"
                        CommandParameter="{Binding StopsFilter}"/>
                    <ScrollViewer
                        Margin="0 25 0 0"
                        VerticalAlignment="Stretch"
                        HorizontalAlignment="Stretch"
                        HorizontalScrollBarVisibility="Hidden"
                        >
                        <ItemsControl
                            Style="{StaticResource StopsListStyle}"
                            ItemsSource="{Binding StopsList.Stops}">                
                        </ItemsControl>
                    </ScrollViewer>
                </Grid>
            </Border>
        
        <!-- Map Pane -->
        <Border Style="{StaticResource MapPaneStyle}"
            
            Grid.Column="1"
            Grid.Row="0"
            >
                <Grid
                 HorizontalAlignment="Stretch"                 
                 x:Name="MapGrid">               
                    
                    <!-- InfoStra.VE (BingMaps3d) Map Control -->
                    <ve:VEMap
                    x:Name="Map"
                    local:Bing3dMapBehaviors.Show3DBuildings="{Binding Show3DBuildings}"                    
                    HorizontalAlignment="Stretch"
                    VerticalAlignment="Stretch"                                        
                    HorizontalContentAlignment="Stretch"
                    Width="{Binding ElementName=MapGrid, Path=ActualWidth}"
                    local:Bing3dMapBehaviors.StartupLatLong="{Binding StartupLatLong}"
                    local:Bing3dMapBehaviors.FlyLatLong="{Binding CurrLatLong}" />
                    <!--ItemsSource="{Binding StopsList.Stops, Converter={StaticResource StopToPushPinCvt}}"-->
                </Grid>
            </Border>
        
        <!-- Bottom Pane -->
        <Border Style="{StaticResource BottomPaneStyle}"
            
            Grid.Column="0" Grid.ColumnSpan="2"
            Grid.Row="1"            
            >
                <Grid Name="ChartParent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
                    <TextBlock 
                        x:Name="LoadingText" 
                        Text="Loading..." 
                        Foreground="White" 
                        Opacity="0" 
                        Visibility="{Binding LoadingVis}" 
                        Style="{StaticResource LoadyStyle}">                        
                    </TextBlock>
                    <TextBlock
                        HorizontalAlignment="Center"
                        Text="{Binding FaresList.FaresTotal, StringFormat='Showing {0:c} in Fares'}"
                        Foreground="White"
                        />
                    <chartingToolkit:Chart
                        Margin="0 20 0 0"                        
                        HorizontalAlignment="Stretch"
                        VerticalAlignment="Stretch" Style="{DynamicResource ChartStyle1}">
                        <chartingToolkit:AreaSeries
                            Title="Fares By Time"
                            ItemsSource="{Binding FaresList.Fares}"
                            DependentValuePath="FareTotal"
                            IndependentValuePath="QuarterHour" Style="{DynamicResource AreaSeriesStyle1}"
                            >
                            
                            </chartingToolkit:AreaSeries>
                    <chartingToolkit:Chart.Axes>
                        <chartingToolkit:LinearAxis
                            ShowGridLines="False"
                            Title="Fare Total"                            
                            Orientation="Y"
                            Minimum="0"                            
                            Foreground="White"
                            />
                        <chartingToolkit:DateTimeAxis
                            Title="Time of Day"
                            Orientation="X">
                            <chartingToolkit:DateTimeAxis.AxisLabelStyle>
                                <Style TargetType="chartingToolkit:DateTimeAxisLabel">
                                    <Setter Property="StringFormat" Value="{}{0:t}" />
                                        <Setter Property="Foreground">
                                            <Setter.Value>
                                                <SolidColorBrush Color="White"></SolidColorBrush>
                                            </Setter.Value>
                                        </Setter>
                                    </Style>
                            </chartingToolkit:DateTimeAxis.AxisLabelStyle>
                            </chartingToolkit:DateTimeAxis>
                    </chartingToolkit:Chart.Axes>
                </chartingToolkit:Chart>       
                </Grid>         
        </Border>
        
    </Grid>
    </Grid>
</Window>
